<!DOCTYPE html>












  




<html class="theme-next gemini use-motion" lang="zh-CN">
<head>
  <!-- hexo-inject:begin --><!-- hexo-inject:end --><meta charset="UTF-8"/>
<meta name="google-site-verification" content="o9IkI77-fxkhBZW-n0ww9JALMCqdDbeTgdcXO_Bw4Zc" />
<meta name="baidu-site-verification" content="3frqY9KiVO" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2"/>
<meta name="theme-color" content="#222">



  
  
  <link rel="stylesheet" href="/lib/needsharebutton/needsharebutton.css">










<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />



















  
  
  
  

  
    
    
  

  
    
      
    

    
  

  

  
    
      
    

    
  

  
    
      
    

    
  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Monda:300,300italic,400,400italic,700,700italic|Roboto Slab:300,300italic,400,400italic,700,700italic|Lobster Two:300,300italic,400,400italic,700,700italic|PT Mono:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=6.4.1" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/logo.png?v=6.4.1">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/logo.png?v=6.4.1">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/logo.png?v=6.4.1">


  <link rel="mask-icon" href="/images/logo.svg?v=6.4.1" color="#222">









<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '6.4.1',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: false,
    fastclick: false,
    lazyload: false,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>


  




  <meta name="description" content="摘要：数学在计算机科学、机器学习、深度学习、自然语言处理等多个领域占据比较重要的位置。比如：特征值和特征向量在PCA降维中会使用；均值在回归算法中估计公式参数中使用；期望和均值在回归方程应用；余弦定理求相似度中运用；拉格朗日定理在支持向量机中使用；求导在解决梯度下降中使用；矩阵和向量在数据格式转换和预处理中运用等等。还有在算法建模、参数设置、验证策略、识别欠拟合和过拟合等方面依然应用广泛。本系列">
<meta name="keywords" content="数学,向量">
<meta property="og:type" content="article">
<meta property="og:title" content="编程数学之向量">
<meta property="og:url" content="https://bainingchao.github.io/2018/10/10/编程数学之向量/index.html">
<meta property="og:site_name" content="白宁超的官网">
<meta property="og:description" content="摘要：数学在计算机科学、机器学习、深度学习、自然语言处理等多个领域占据比较重要的位置。比如：特征值和特征向量在PCA降维中会使用；均值在回归算法中估计公式参数中使用；期望和均值在回归方程应用；余弦定理求相似度中运用；拉格朗日定理在支持向量机中使用；求导在解决梯度下降中使用；矩阵和向量在数据格式转换和预处理中运用等等。还有在算法建模、参数设置、验证策略、识别欠拟合和过拟合等方面依然应用广泛。本系列">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="https://i.imgur.com/SEzkDyk.png">
<meta property="og:image" content="https://i.imgur.com/gg3uO9i.png">
<meta property="og:image" content="https://i.imgur.com/0ThOOru.png">
<meta property="og:image" content="http://pub.idqqimg.com/wpa/images/group.png">
<meta property="og:image" content="https://i.imgur.com/cvixeiT.png">
<meta property="og:updated_time" content="2018-10-19T07:41:37.748Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="编程数学之向量">
<meta name="twitter:description" content="摘要：数学在计算机科学、机器学习、深度学习、自然语言处理等多个领域占据比较重要的位置。比如：特征值和特征向量在PCA降维中会使用；均值在回归算法中估计公式参数中使用；期望和均值在回归方程应用；余弦定理求相似度中运用；拉格朗日定理在支持向量机中使用；求导在解决梯度下降中使用；矩阵和向量在数据格式转换和预处理中运用等等。还有在算法建模、参数设置、验证策略、识别欠拟合和过拟合等方面依然应用广泛。本系列">
<meta name="twitter:image" content="https://i.imgur.com/SEzkDyk.png">



  <link rel="alternate" href="/atom.xml" title="白宁超的官网" type="application/atom+xml" />




  <link rel="canonical" href="https://bainingchao.github.io/2018/10/10/编程数学之向量/"/>



<script type="text/javascript" id="page.configurations">
  CONFIG.page = {
    sidebar: "",
  };
</script>

  <title>编程数学之向量 | 白宁超的官网</title>
  









  <noscript>
  <style type="text/css">
    .use-motion .motion-element,
    .use-motion .brand,
    .use-motion .menu-item,
    .sidebar-inner,
    .use-motion .post-block,
    .use-motion .pagination,
    .use-motion .comments,
    .use-motion .post-header,
    .use-motion .post-body,
    .use-motion .collection-title { opacity: initial; }

    .use-motion .logo,
    .use-motion .site-title,
    .use-motion .site-subtitle {
      opacity: initial;
      top: initial;
    }

    .use-motion {
      .logo-line-before i { left: initial; }
      .logo-line-after i { right: initial; }
    }
  </style>
</noscript><!-- hexo-inject:begin --><!-- hexo-inject:end -->

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN">

  
  
    
  

  <!-- hexo-inject:begin --><!-- hexo-inject:end --><div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

	<!-- <a href="https://github.com/bainingchao"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub"></a> !-->
	
    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">白宁超的官网</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
    
      
        <h1 class="site-subtitle" itemprop="description">专注人工智能领域研究</h1>
      
    
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>



<nav class="site-nav">
  
    <ul id="menu" class="menu">
      
        
        
        
          
          <li class="menu-item menu-item-首页">
    <a href="/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-home"></i> <br />首页</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-标签">
    <a href="/tags/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />标签</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-分类">
    <a href="/categories/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-th"></i> <br />分类</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-归档">
    <a href="/archives/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />归档</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-视频">
    <a href="/videos/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-sitemap"></i> <br />视频</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-书籍">
    <a href="/books/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-th"></i> <br />书籍</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-链接">
    <a href="/links/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-question-circle"></i> <br />链接</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-关于">
    <a href="/about/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-user"></i> <br />关于</a>
  </li>

      
      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />搜索</a>
        </li>
      
    </ul>
  

  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off"
             placeholder="搜索..." spellcheck="false"
             type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



  



</div>
    </header>

    


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          
            

          
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://bainingchao.github.io/2018/10/10/编程数学之向量/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="白宁超">
      <meta itemprop="description" content="本站主要研究深度学习、机器学习、自然语言处理等前沿技术。ML&NLP交流群：436303759 <span><a target="_blank" href="http://shang.qq.com/wpa/qunwpa?idkey=ef3bbb679b06ac59b136c57ba9e7935ff9d3b10faeabde6e4efcafe523bbbf4d"><img border="0" src="http://pub.idqqimg.com/wpa/images/group.png" alt="自然语言处理和机器学习技术QQ交流：436303759 " title="自然语言处理和机器学习技术交流"></a></span>">
      <meta itemprop="image" content="/../images/header.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="白宁超的官网">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">编程数学之向量
              
            
          </h2>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              

              
                
              

              <time title="创建时间：2018-10-10 14:16:06" itemprop="dateCreated datePublished" datetime="2018-10-10T14:16:06+08:00">2018-10-10</time>
            

            
              

              
                
                <span class="post-meta-divider">|</span>
                

                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                
                  <span class="post-meta-item-text">更新于</span>
                
                <time title="修改时间：2018-10-19 15:41:37" itemprop="dateModified" datetime="2018-10-19T15:41:37+08:00">2018-10-19</time>
              
            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/数学/" itemprop="url" rel="index"><span itemprop="name">数学</span></a></span>

                
                
                  ，
                
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/数学/向量/" itemprop="url" rel="index"><span itemprop="name">向量</span></a></span>

                
                
              
            </span>
          

          
            
          

          
          

          
            <span class="post-meta-divider">|</span>
            <span class="post-meta-item-icon"
            >
            <i class="fa fa-eye"></i>
             阅读次数： 
            <span class="busuanzi-value" id="busuanzi_value_page_pv" ></span>
            </span>
          
		  

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <blockquote>
<p>摘要：数学在计算机科学、机器学习、深度学习、自然语言处理等多个领域占据比较重要的位置。比如：特征值和特征向量在PCA降维中会使用；均值在回归算法中估计公式参数中使用；期望和均值在回归方程应用；余弦定理求相似度中运用；拉格朗日定理在支持向量机中使用；求导在解决梯度下降中使用；矩阵和向量在数据格式转换和预处理中运用等等。还有在算法建模、参数设置、验证策略、识别欠拟合和过拟合等方面依然应用广泛。本系列数学文章旨在带领大家快速回顾常用知识，重在理解。（本文原创，转载必须注明出处.）</p>
</blockquote>
<a id="more"></a>
<hr>
<h1 id="向量定义"><a href="#向量定义" class="headerlink" title="向量定义"></a>向量定义</h1><h2 id="向量"><a href="#向量" class="headerlink" title="向量"></a>向量</h2><p>向量也称为欧几里得向量、几何向量、矢量，指具有大小和方向的量。它可以形象化地表示为带箭头的线段。箭头所指：代表向量的方向；线段长度：代表向量的大小。与向量对应的只有大小，没有方向的量叫做标量。</p>
<h2 id="零向量"><a href="#零向量" class="headerlink" title="零向量"></a>零向量</h2><p>始点与终点重合，也就是重合点的向量。 \( \vec{0}=\vec{AA}=\vec{BB}=.. \)，具有方向性，但方向不定。因此，零向量与任一向量平行。</p>
<h2 id="等向量"><a href="#等向量" class="headerlink" title="等向量"></a>等向量</h2><p>两向量长度、方向相等，即为等向量</p>
<h2 id="有向线段"><a href="#有向线段" class="headerlink" title="有向线段"></a>有向线段</h2><p>有向线段的概念建构于向量的方向与长度，差别在于多定义了始点与终点。在文字描述时，如果已知某有向线段的起点和终点分别是A和B，此线段的长度可以记为\(|\vec {AB} |\) ，即  </p>
<script type="math/tex; mode=display">|\overrightarrow {AB}|=|\overline {AB} |</script><h2 id="向量的记法"><a href="#向量的记法" class="headerlink" title="向量的记法"></a>向量的记法</h2><p>向量由方向和长度两个因素所组成，可以记为 \( \vec{a} \)。</p>
<h2 id="数量积"><a href="#数量积" class="headerlink" title="数量积"></a>数量积</h2><p>数量积也叫点积，它是向量与向量的乘积，其结果为一个标量（非向量）。几何上，数量积可以定义如下：<br>设\( \vec {A} \)、\( \vec {B} \) 为两个任意向量，它们的夹角为 \( \theta \)，则他们的数量积为：</p>
<script type="math/tex; mode=display">\vec{A} \cdot \vec {B}=\left|\vec{A}\right|\left|\vec{B}\right|\cos\theta</script><p>即\( \vec {A} \)向量在\( \vec {B} \)向量方向上的投影长度（同方向为正反方向为负号），与\( \vec {B} \)向量长度的乘积。 数量积被广泛应用于物理中，如做功就是用力的向量乘位移的向量，即\( W= \vec {F} \cdot  \vec {s}   \) </p>
<h2 id="向量积"><a href="#向量积" class="headerlink" title="向量积"></a>向量积</h2><p>向量积也叫叉积，外积，它也是向量与向量的乘积，它的结果是个向量。它的几何意义是所得的向量与被乘向量所在平面垂直，方向由右手定则规定，大小是两个被乘向量张成的平行四边形的面积。所以向量积不满足交换律。举例来说:</p>
<script type="math/tex; mode=display">(1,0,0)\times (0,1,0)=(0,0,1)</script><script type="math/tex; mode=display">(0,1,0)\times (1,0,0)=(0,0,-1)</script><p>设有向量 </p>
<script type="math/tex; mode=display">\vec{A} =( A_x\vec{i},A_y\vec{j},A_z\vec{k} )</script><script type="math/tex; mode=display">\vec{B}=(B_x\vec{i},B_y\vec{j},B_z\vec{k})</script><p>则其向量积的矩阵表达式可用下列符号表示：</p>
<script type="math/tex; mode=display">
\vec{A}\times\vec{B}=
\begin{vmatrix}
    \vec{i}&\vec{j}&\vec{k} \\\
    A_x&A_y&A_z \\\
    B_x&B_y&B_z \\\
\end{vmatrix}</script><h2 id="线性相关性"><a href="#线性相关性" class="headerlink" title="线性相关性"></a>线性相关性</h2><p>\({\vec {v}}_1,{\vec {v}}_2,…,{\vec {v}}_m\)</p>
<p>对于m个向量 \( \vec{v}_1,\vec{v}_2,…,\vec{v}_m \)</p>
<p>如果存在一组不全为零的m个数\( \vec{a}_1,\vec{a}_2,…,\vec{a}_m \)</p>
<p>\( {\displaystyle {\sum_{i=1}^m a_i{\vec{v}}_i}}=\vec{0} \)</p>
<p>那么，称 m个向量  \({\displaystyle {\vec {v}}_1},{\displaystyle {\vec {v}}_2},…,{\displaystyle {\vec {v}}_m} \)线性相关。如果这样不全为零的m个数不存在，即上述向量等式仅当\( {\displaystyle a_1} = {\displaystyle a_2} = … = {\displaystyle a_m}  = 0 \)时才能成立，就称向量 \({\displaystyle {\vec {v}}_1},{\displaystyle {\vec {v}}_2},…,{\displaystyle {\vec {v}}_m} \)线性无关。</p>
<h2 id="例子解析"><a href="#例子解析" class="headerlink" title="例子解析"></a>例子解析</h2><p>某人家门口是一条南北向的道路。他散步时先向南行走100米，那么他位置的移动就可以用一个大小为100米，方向为南的向量来表示。之后他再向北走300米，这一次的移动可以用一个大小为300米，方向为北的向量来表示。散步的人总共相对于他家的位移则可以用大小为200米，方向为北的向量来表示。几何学上看来，这些向量都在同一条一维的直线上，只有两个互相平行的方向。</p>
<hr>
<h1 id="向量运算"><a href="#向量运算" class="headerlink" title="向量运算"></a>向量运算</h1><h2 id="代数表示"><a href="#代数表示" class="headerlink" title="代数表示"></a>代数表示</h2><p>一般计算机上采用加粗小写英文字母如：（<strong>a</strong>、<strong>b</strong>、<strong>c</strong>等）来表示；手写用在a、b、c等字母上加一箭头（→）表示，如 \( \vec{a}\vec{b}\vec{c} \)。</p>
<h2 id="几何表示"><a href="#几何表示" class="headerlink" title="几何表示"></a>几何表示</h2><p>向量可以用有向线段来表示。有向线段的长度表示向量的大小，向量的大小，也就是向量的长度。长度为0的向量叫做零向量，记作长度等于1个单位的向量，叫做单位向量。向量表示箭头所指的方向表示向量的方向，如图所示。 </p>
<p><img src="https://i.imgur.com/SEzkDyk.png" alt=""></p>
<h2 id="向量定理"><a href="#向量定理" class="headerlink" title="向量定理"></a>向量定理</h2><blockquote>
<p>共线定理</p>
</blockquote>
<p>若b≠0，则a//b的充要条件是存在唯一实数λ，使 \( \vec{a}=\lambda\vec{b} \)。若设\(a=(x_1,y_1)，b=(x_2,y_2)\) ，则有 \( x_1*y_2=x_2*y_1 \)，与平行概念相同。<br> \( \vec{0} \)平行于任何向量。</p>
<blockquote>
<p>垂直定理</p>
</blockquote>
<p>a⊥b的充要条件是<strong>a·b</strong>=0，即\( x_1x_2+y_1y_2=0 \) 。</p>
<h2 id="加法"><a href="#加法" class="headerlink" title="加法"></a>加法</h2><p>向量的加法满足平行四边形法则和三角形法则。两个向量 \( \vec{a} \) 和 \( \vec{b} \)相加，得到的是另一个向量。这个向量可以表示为  \( \vec{a} \) 和 \( \vec{b} \)的起点重合后，以它们为邻边构成的平行四边形的一条对角线（以共同的起点为起点的那一条，如图所示），或者表示为将 \( \vec{a} \)的终点和\( \vec{b} \)的起点重合后，从\( \vec{a} \)的起点指向 \( \vec{b} \)的终点的向量</p>
<p><img src="https://i.imgur.com/gg3uO9i.png" alt=""></p>
<p><strong>例子：</strong></p>
<p>\( \vec{a}=(x_1,y_1),\vec{b}=(x_2,y_2) \) 则:<br>\( \vec{a}+ \vec{b} = (x_1+x_2,y_1+y_2)\)</p>
<p>向量加法的运算律：</p>
<p>\( \vec{a}+ \vec{0} = \vec{0}+ \vec{a}= \vec{a}\)</p>
<p>交换律：<br>\( \vec{a}+ \vec{b} = \vec{b}+ \vec{a}\)<br>结合律：<br>\( \vec{a}+ \vec{b})+ \vec{c}= \vec{a}+(\vec{b}+ \vec{c})\)</p>
<h2 id="减法"><a href="#减法" class="headerlink" title="减法"></a>减法</h2><p>两个向量  \( \vec{a} \)和 \( \vec{b} \)的相减，则可以看成是向量 \( \vec{a} \)加上一个与 \( \vec{b} \)大小相等，方向相反的向量。换言之，\( \vec{a} \)和 \( \vec{b} \)的的相减得到的向量可以表示为\( \vec{a} \)和 \( \vec{b} \)的起点重合后，从 \( \vec{b} \)的终点指向 \( \vec{a} \)的终点的向量，如图所示。</p>
<p><img src="https://i.imgur.com/0ThOOru.png" alt=""></p>
<p><strong>例子：</strong></p>
<p>\(\vec{a}=(x_1,y_1),\vec{b}=(x_2,y_2)\) 则:<br>\(\vec{a}- \vec{b} = (x_1-x_2,y_1-y_2)\)</p>
<p>加减变换律：</p>
<p>\(\vec{a}+ \vec{(-b)} = \vec{a}- \vec{b}\)</p>
<h2 id="数乘"><a href="#数乘" class="headerlink" title="数乘"></a>数乘</h2><p>一个标量k和一个向量  \( \vec{a} \)之间可以做乘法，得出的结果是另一个与 \( \vec{a} \)方向相同或相反，大小为  \( \vec{a} \)的大小的｜k｜倍的向量，可以记成 \( k\vec{a} \)。</p>
<ul>
<li>当k&gt;0时， \( k\vec{a} \)的方向与 \( \vec{a} \)的方向相同。</li>
<li>当k&lt;0时， \( k\vec{a} \)的方向与 \( \vec{a} \)的方向相反。</li>
<li>当k=0时， \( k\vec{a}=\vec{0} \)，方向任意。当\( \vec{a}=0\)时，对于任意实数k，都有\( k\vec{a}=\vec{0} \)。</li>
</ul>
<p>-1乘以任意向量会得到它的反向量，0乘以任何向量都会得到零向量 \( \vec{0}\)。</p>
<p><strong>数与向量满足运算律</strong></p>
<p>结合律： \( (k\vec{a})\vec{b}=k(\vec{a}\vec{b})=(\vec{a}k\vec{b}) \)</p>
<p>向量对于数的分配律（第一分配律）： \( (k+m)\vec{a}=k\vec{a}+m\vec{a} \)</p>
<p>数对于向量的分配律（第二分配律）： \( k(\vec{a}+\vec{b})=k\vec{a}+k\vec{b} \)</p>
<p>数乘向量的消去律：</p>
<ol>
<li>如果实数k≠0且\( k\vec{a}=k\vec{b} \)，那么\(\vec{a}=\vec{b}\)。</li>
<li>如果\( \vec{a}\neq \vec{0}\)且\(k\vec{a}= m\vec{a}\)，那么k=m。</li>
</ol>
<h2 id="数量积-1"><a href="#数量积-1" class="headerlink" title="数量积"></a>数量积</h2><p>定义：已知两个非零向量 \( \vec{a} \)， \( \vec{b} \)。作\( OA= \vec{a}\),\(OB= \vec{b}\)，则∠AOB称作向量 \( \vec{b} \)和向量 \( \vec{a} \)的夹角，记作θ并规定0≤θ≤π</p>
<p>定义：两个向量的数量积（内积、点积）是一个数量（没有方向），记作\( \vec{a}\vec{b}\)。</p>
<ul>
<li>若 \( \vec{a} \)、 \( \vec{b} \)不共线，则 \( \vec{a}*\vec{b}=|a|*|b|*cosθ\)。</li>
<li>若 \( \vec{a} \)、 \( \vec{b} \)共线，则\(\vec{a}*\vec{b}=\pm|a|*|b|\) 。</li>
</ul>
<p>向量的数量积的坐标表示：\(\vec{a} \vec{b} = (x_1x_2+y_1y_2)\) </p>
<h2 id="数量积的运算律"><a href="#数量积的运算律" class="headerlink" title="数量积的运算律"></a>数量积的运算律</h2><p>交换律： \(\vec{a}* \vec{b} = \vec{b}* \vec{a} \)</p>
<p>结合律： \((k\vec{a})* \vec{b} =k(\vec{b}* \vec{a}) \) </p>
<p>分配律：\((\vec{a}+\vec{b})* \vec{c} =\vec{a}* \vec{c}+\vec{b}*\vec{c})\)</p>
<h2 id="向量积-1"><a href="#向量积-1" class="headerlink" title="向量积"></a>向量积</h2><p>定义：两个向量 \( \vec{a} \)和 \( \vec{b} \)的向量积（外积、叉积）是一个向量。记作\(\vec{a} \wedge \vec{b}\)</p>
<ul>
<li>若 \( \vec{a} \)、 \( \vec{b} \)不共线，则\(\vec{a} \wedge \vec{b}\)的模是：\(|\vec{a} \wedge \vec{b}|=|\vec{a}|*|\vec{b}|*sin\langle\vec{a},\vec{b}\rangle\)；\(\vec{a} \wedge \vec{b}\)的方向是：垂直于\( \vec{a} \)和\( \vec{b} \)，且\( \vec{a} \)、\( \vec{b} \)和\(\vec{a} \wedge \vec{b}\)按这个次序构成右手系。</li>
<li>若\( \vec{a} \)、 \( \vec{b} \)垂直，则\(|\vec{a} \wedge \vec{b}|=|\vec{a}|*|\vec{b}|\)（此处与数量积不同，请注意），若\(|\vec{a} \wedge \vec{b}|=\vec{0}\)，则\( \vec{a} \)、\( \vec{b} \)平行。</li>
</ul>
<p>向量积即两个不共线非零向量所在平面的一组法向量。</p>
<h2 id="运算法则：运用三阶行列式"><a href="#运算法则：运用三阶行列式" class="headerlink" title="运算法则：运用三阶行列式"></a>运算法则：运用三阶行列式</h2><p>设\( \vec{a} \)、\( \vec{b} \)、\( \vec{c} \)分别为沿x,y,z轴的单位向量\(A=(x_1,y_1,z_1)\)，\(B=(x_2,y_2,z_2)\)，则</p>
<script type="math/tex; mode=display">A\*B=\begin{bmatrix}
\vec{a} &\vec{b}  & \vec{c}\\ 
 x_1&y_1  &z_1 \\ 
 x_2&y_2  &z_2 
\end{bmatrix}</script><h2 id="向量积性质"><a href="#向量积性质" class="headerlink" title="向量积性质"></a>向量积性质</h2><p>向量积\(|\vec{a} \wedge \vec{b}|\)是以\( \vec{a} \)和\( \vec{b} \)为边的平行四边形面积。<br></p>
<ul>
<li>\(|\vec{a} \wedge \vec{a}|=\vec{0}\)</li>
<li>\(\vec{a}//\vec{b}=\vec{a} \wedge \vec{a}|=\vec{0}\)</li>
</ul>
<h2 id="向量积运算律"><a href="#向量积运算律" class="headerlink" title="向量积运算律"></a>向量积运算律</h2><ul>
<li>\(|\vec{a} \wedge \vec{b}|=\vec{-b} \wedge \vec{a}|\)</li>
<li>\(|(k\vec{a})\wedge \vec{b}=k(\vec{a}\wedge \vec{b})=\vec{a}\wedge (k\vec{b})\)</li>
<li>\(\vec{a} \wedge (\vec{b}+\vec{c})=\vec{a} \wedge \vec{b}+\vec{a} \wedge \vec{c}\)</li>
<li>\((\vec{a} + \vec{b}) \wedge \vec{c}=\vec{a} \wedge \vec{c}+\vec{a} \wedge \vec{c}\)</li>
</ul>
<p>\(a×(b+c)=a×b+a×c\).<br>\((a+b)×c=a×c+b×c\).<br>上两个分配律分别称为左分配律和右分配律。在演算中应注意不能交换“×”号两侧向量的次序。<br>注：向量没有除法，“向量AB/向量CD”是没有意义的。</p>
<h2 id="向量的模长-范数"><a href="#向量的模长-范数" class="headerlink" title="向量的模长(范数)"></a>向量的模长(范数)</h2><p>向量的大小也叫做<strong>范数</strong>或者模长，有限维空间中，已知向量的坐标，就可以知道它的模长。设向量\( vec {v}=(v_1,v_2,\cdots ,v_n)\)，</p>
<p>范数记作：\({\displaystyle \left|{\vec {v}}\right|} \)</p>
<p>模长记作：\({\displaystyle \left|{\vec {v}}\right|} \)</p>
<p>计算表达式由弗罗贝尼乌斯范数（一种同时适用于向量和矩阵的范数计算方法）给出：<br>\( \left|{\vec {v}}\right|={\sqrt {v_1^{2}+v_2^{2}+\cdots +v_n^{2}}} \)</p>
<p>或：<br>\( \left|{\vec {v}}\right|={\sqrt {v_1^{2}+v_2^{2}+\cdots +v_n^{2}}}\)</p>
<hr>
<h1 id="参考文献"><a href="#参考文献" class="headerlink" title="参考文献"></a>参考文献</h1><ol>
<li><a href="https://www.python.org/downloads/" target="_blank" rel="noopener">Python官网</a></li>
<li><a href="https://zh.wikipedia.org/wiki/Python" target="_blank" rel="noopener">中文维基百科</a></li>
<li><a href="https://github.com/BaiNingchao/MachineLearning-1" target="_blank" rel="noopener">GitHub</a></li>
<li>图书：《机器学习实战》</li>
<li><a href="https://baike.baidu.com/item/%E8%87%AA%E7%84%B6%E8%AF%AD%E8%A8%80%E5%A4%84%E7%90%86%E7%90%86%E8%AE%BA%E4%B8%8E%E5%AE%9E%E6%88%98" target="_blank" rel="noopener">图书：《自然语言处理理论与实战》</a></li>
</ol>
<h1 id="完整代码下载"><a href="#完整代码下载" class="headerlink" title="完整代码下载"></a>完整代码下载</h1><blockquote>
<p>源码请进【机器学习和自然语言QQ群：436303759】文件下载：<a target="_blank" href="http://shang.qq.com/wpa/qunwpa?idkey=ef3bbb679b06ac59b136c57ba9e7935ff9d3b10faeabde6e4efcafe523bbbf4d"><img border="0" src="http://pub.idqqimg.com/wpa/images/group.png" alt="自然语言处理和机器学习技术QQ交流" title="自然语言处理和机器学习技术交流"></a></p>
</blockquote>
<p><img src="https://i.imgur.com/cvixeiT.png" alt=""></p>
<h1 id="作者声明"><a href="#作者声明" class="headerlink" title="作者声明"></a>作者声明</h1><blockquote>
<p>本文版权归作者所有，旨在技术交流使用。未经作者同意禁止转载，转载后需在文章页面明显位置给出原文连接，否则相关责任自行承担。</p>
</blockquote>

      
    </div>

    

    
    
    

    
      <div>
        <div id="wechat_subscriber" style="display: block; padding: 10px 0; margin: 20px auto; width: 100%; text-align: center">
    <img id="wechat_subscriber_qcode" src="/uploads/wechat.png" alt="白宁超 wechat" style="width: 200px; max-width: 100%;"/>
    <div>扫一扫关注微信公众号，机器学习和自然语言处理，订阅号datathinks！</div>
</div>

      </div>
    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div></div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>打赏</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="/images/wechatpay.jpg" alt="白宁超 微信支付"/>
        <p>微信支付</p>
      </div>
    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="/images/alipay.jpg" alt="白宁超 支付宝"/>
        <p>支付宝</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/数学/" rel="tag"><i class="fa fa-tag"></i> 数学</a>
          
            <a href="/tags/向量/" rel="tag"><i class="fa fa-tag"></i> 向量</a>
          
        </div>
      

      
      
        <div class="post-widgets">
        

        

        
          
          <div class="social_share">
            
               <div>
                 
  <div class="bdsharebuttonbox">
    <a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
    <a href="#" class="bds_douban" data-cmd="douban" title="分享到豆瓣网"></a>
    <a href="#" class="bds_sqq" data-cmd="sqq" title="分享到QQ好友"></a>
    <a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a>
    <a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a>
    <a href="#" class="bds_tieba" data-cmd="tieba" title="分享到百度贴吧"></a>
    <a href="#" class="bds_twi" data-cmd="twi" title="分享到Twitter"></a>
    <a href="#" class="bds_fbook" data-cmd="fbook" title="分享到Facebook"></a>
    <a href="#" class="bds_more" data-cmd="more"></a>
    <a class="bds_count" data-cmd="count"></a>
  </div>
  <script>
    window._bd_share_config = {
      "common": {
        "bdText": "",
        "bdMini": "2",
        "bdMiniList": false,
        "bdPic": ""
      },
      "share": {
        "bdSize": "16",
        "bdStyle": "0"
      },
      "image": {
        "viewList": ["tsina", "douban", "sqq", "qzone", "weixin", "twi", "fbook"],
        "viewText": "分享到：",
        "viewSize": "16"
      }
    }
  </script>

<script>
  with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='/static/api/js/share.js?cdnversion='+~(-new Date()/36e5)];
</script>

               </div>
            
            
               <div id="needsharebutton-postbottom">
                 <span class="btn">
                    <i class="fa fa-share-alt" aria-hidden="true"></i>
                 </span>
               </div>
            
          </div>
        
        </div>
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2018/10/10/简明的Python教程之NumPy/" rel="next" title="简明的Python教程之NumPy">
                <i class="fa fa-chevron-left"></i> 简明的Python教程之NumPy
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2018/10/10/编程数学之矩阵/" rel="prev" title="编程数学之矩阵">
                编程数学之矩阵 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>


  </div>


          </div>
          

  
    <div class="comments" id="comments">
      <div id="lv-container" data-id="city" data-uid="MTAyMC8zOTc5NC8xNjMyMQ=="></div>
    </div>

  
 





        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="/../images/header.png"
                alt="白宁超" />
            
              <p class="site-author-name" itemprop="name">白宁超</p>
              <p class="site-description motion-element" itemprop="description">本站主要研究深度学习、机器学习、自然语言处理等前沿技术。ML&NLP交流群：436303759 <span><a target="_blank" href="http://shang.qq.com/wpa/qunwpa?idkey=ef3bbb679b06ac59b136c57ba9e7935ff9d3b10faeabde6e4efcafe523bbbf4d"><img border="0" src="http://pub.idqqimg.com/wpa/images/group.png" alt="自然语言处理和机器学习技术QQ交流：436303759 " title="自然语言处理和机器学习技术交流"></a></span></p>
          </div>

          
            <nav class="site-state motion-element">
              
                <div class="site-state-item site-state-posts">
                
                  <a href="/archives">
                
                    <span class="site-state-item-count">65</span>
                    <span class="site-state-item-name">日志</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-categories">
                  <a href="/categories/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">29</span>
                    <span class="site-state-item-name">分类</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-tags">
                  <a href="/tags/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">119</span>
                    <span class="site-state-item-name">标签</span>
                  </a>
                </div>
              
            </nav>
          

          
            <div class="feed-link motion-element">
              <a href="/atom.xml" rel="alternate">
                <i class="fa fa-rss"></i>
                RSS
              </a>
            </div>
          

          
            <div class="links-of-author motion-element">
              
                <span class="links-of-author-item">
                  <a href="https://github.com/bainingchao" target="_blank" title="GitHub" rel="external nofollow"><i class="fa fa-fw fa-github"></i>GitHub</a>
                  
                </span>
              
                <span class="links-of-author-item">
                  <a href="https://www.google.com.hk/" target="_blank" title="Google" rel="external nofollow"><i class="fa fa-fw fa-google"></i>Google</a>
                  
                </span>
              
                <span class="links-of-author-item">
                  <a href="https://www.baidu.com/" target="_blank" title="百度" rel="external nofollow"><i class="fa fa-fw fa-globe"></i>百度</a>
                  
                </span>
              
                <span class="links-of-author-item">
                  <a href="https://weibo.com/p/1005056002073632?is_all=1" target="_blank" title="微博" rel="external nofollow"><i class="fa fa-fw fa-weibo"></i>微博</a>
                  
                </span>
              
                <span class="links-of-author-item">
                  <a href="http://www.cnblogs.com/baiboy/" target="_blank" title="博客园" rel="external nofollow"><i class="fa fa-fw fa-globe"></i>博客园</a>
                  
                </span>
              
                <span class="links-of-author-item">
                  <a href="https://mp.weixin.qq.com/s/s97I4gtEJIt5rMivWMkPkQ" target="_blank" title="微信公众号" rel="external nofollow"><i class="fa fa-fw fa-weixin"></i>微信公众号</a>
                  
                </span>
              
            </div>
          

          
          

          
          

          
            
          
          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#向量定义"><span class="nav-number">1.</span> <span class="nav-text">向量定义</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#向量"><span class="nav-number">1.1.</span> <span class="nav-text">向量</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#零向量"><span class="nav-number">1.2.</span> <span class="nav-text">零向量</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#等向量"><span class="nav-number">1.3.</span> <span class="nav-text">等向量</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#有向线段"><span class="nav-number">1.4.</span> <span class="nav-text">有向线段</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#向量的记法"><span class="nav-number">1.5.</span> <span class="nav-text">向量的记法</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#数量积"><span class="nav-number">1.6.</span> <span class="nav-text">数量积</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#向量积"><span class="nav-number">1.7.</span> <span class="nav-text">向量积</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#线性相关性"><span class="nav-number">1.8.</span> <span class="nav-text">线性相关性</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#例子解析"><span class="nav-number">1.9.</span> <span class="nav-text">例子解析</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#向量运算"><span class="nav-number">2.</span> <span class="nav-text">向量运算</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#代数表示"><span class="nav-number">2.1.</span> <span class="nav-text">代数表示</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#几何表示"><span class="nav-number">2.2.</span> <span class="nav-text">几何表示</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#向量定理"><span class="nav-number">2.3.</span> <span class="nav-text">向量定理</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#加法"><span class="nav-number">2.4.</span> <span class="nav-text">加法</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#减法"><span class="nav-number">2.5.</span> <span class="nav-text">减法</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#数乘"><span class="nav-number">2.6.</span> <span class="nav-text">数乘</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#数量积-1"><span class="nav-number">2.7.</span> <span class="nav-text">数量积</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#数量积的运算律"><span class="nav-number">2.8.</span> <span class="nav-text">数量积的运算律</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#向量积-1"><span class="nav-number">2.9.</span> <span class="nav-text">向量积</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#运算法则：运用三阶行列式"><span class="nav-number">2.10.</span> <span class="nav-text">运算法则：运用三阶行列式</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#向量积性质"><span class="nav-number">2.11.</span> <span class="nav-text">向量积性质</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#向量积运算律"><span class="nav-number">2.12.</span> <span class="nav-text">向量积运算律</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#向量的模长-范数"><span class="nav-number">2.13.</span> <span class="nav-text">向量的模长(范数)</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#参考文献"><span class="nav-number">3.</span> <span class="nav-text">参考文献</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#完整代码下载"><span class="nav-number">4.</span> <span class="nav-text">完整代码下载</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#作者声明"><span class="nav-number">5.</span> <span class="nav-text">作者声明</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
</script>

<div class="copyright">&copy; <span itemprop="copyrightYear">2019</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">白宁超</span>

  

  
</div>




  



  <!--<div class="powered-by">由 <a class="theme-link" target="_blank" rel="external nofollow" href="https://hexo.io">Hexo</a> 强力驱动 v3.7.1</div> -->



   <!--<span class="post-meta-divider">|</span>-->



   <!--<div class="theme-info">主题 – <a class="theme-link" target="_blank" rel="external nofollow" href="https://theme-next.org">NexT.Gemini</a> v6.4.1</div>-->




        <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>



<div class="busuanzi-count">
  
    <span class="site-uv" title="总访客量">
      <i class="fa fa-user"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
    </span>
  

  
    <span class="site-pv" title="总访问量">
      <i class="fa fa-eye"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
    </span>
  
</div>









        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    
	
    

    
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>


























  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=6.4.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=6.4.1"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=6.4.1"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=6.4.1"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=6.4.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=6.4.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=6.4.1"></script>



  



  
    <script type="text/javascript">
      window.livereOptions = {
        refer: '2018/10/10/编程数学之向量/'
      };
      (function(d, s) {
        var j, e = d.getElementsByTagName(s)[0];
        if (typeof LivereTower === 'function') { return; }
        j = d.createElement(s);
        j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
        j.async = true;
        e.parentNode.insertBefore(j, e);
      })(document, 'script');
    </script>
  










  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  

  

  
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


  
  

  
  

  
    
      <script type="text/x-mathjax-config">
    MathJax.Hub.Config({
      tex2jax: {
        inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
        processEscapes: true,
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
      },
      TeX: {equationNumbers: { autoNumber: "AMS" }}
    });
</script>

<script type="text/x-mathjax-config">
    MathJax.Hub.Queue(function() {
      var all = MathJax.Hub.getAllJax(), i;
        for (i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
        }
    });
</script>
<script type="text/javascript" src="//cdn.jsdelivr.net/npm/mathjax@2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>

    
  


  
  
  
  <script src="/lib/needsharebutton/needsharebutton.js"></script>

  <script>
    
      pbOptions = {};
      
          pbOptions.iconStyle = "box";
      
          pbOptions.boxForm = "horizontal";
      
          pbOptions.position = "bottomCenter";
      
          pbOptions.networks = "Weibo,Wechat,Douban,QQZone,Linkedin,Facebook";
      
      new needShareButton('#needsharebutton-postbottom', pbOptions);
    
    
  </script>

  

  

  

  

  

  

  <!-- 页面点击小红心 -->
	<script type="text/javascript" src="../js/src/love.js"></script><!-- hexo-inject:begin --><!-- Begin: Injected MathJax -->
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({"tex2jax":{"inlineMath":[["$","$"],["\\(","\\)"]],"skipTags":["script","noscript","style","textarea","pre","code"],"processEscapes":true},"TeX":{"equationNumbers":{"autoNumber":"AMS"}}});
</script>

<script type="text/x-mathjax-config">
  MathJax.Hub.Queue(function() {
    var all = MathJax.Hub.getAllJax(), i;
    for(i=0; i < all.length; i += 1) {
      all[i].SourceElement().parentNode.className += ' has-jax';
    }
  });
</script>

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js">
</script>
<!-- End: Injected MathJax -->
<!-- hexo-inject:end -->
</body>
</html>
